# 场区里的块类，块：长方体的区域，有数十个 Bay位，

import constant as constant


class Block(object):
    def __init__(self, id, x, y,point_id):
        '''
        构造函数
        :param id: Block的编号
        :param x:  块左边的中点 x 坐标
        :param y:  块左边的中点 y 坐标
        :param point_id: block区域距离最近的地图上的节点
        '''
        self.id = id
        self.bay_list = []
        self.x, self.y = x, y
        self.point_id=point_id
        self.wait_list=[]

    def add_bay(self, bay):
        '''
        向Block的bay_list中添加bay
        :param bay:
        :return:
        '''
        if (len(self.bay_list) < constant.block_num_bay):
            self.bay_list.append(bay)
            return True
        else:
            return False

    def add_waitBox(self,box):
        self.wait_list.append(box)

    def handle_waitBox(self):
        pass

    def add_box(self,box):
        for bay in self.bay_list:
            if(bay.add_box(box)):
                return True
        return False


